package com.example.activiti.common.cmd;

import org.activiti.engine.impl.cmd.NeedsActiveTaskCmd;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntityManagerImpl;

@SuppressWarnings("serial")
public class TaskDeleteCmd extends NeedsActiveTaskCmd<String> {
	public TaskDeleteCmd(String taskId) {  
        super(taskId);  
    }  
    @Override  
    public String execute(CommandContext commandContext, TaskEntity currentTask) {  
        TaskEntityManagerImpl taskEntityManager = (TaskEntityManagerImpl) commandContext.getTaskEntityManager();  
        ExecutionEntity executionEntity = currentTask.getExecution();  
        taskEntityManager.deleteTask(currentTask, "reject", false, false);  
        return executionEntity.getId();  
    }  
}
